package com.cuitrip.business.order;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.cuitrip.business.home.IndexActivity;
import com.cuitrip.business.login.LoginInstance;
import com.cuitrip.business.order.model.OrderItem;
import com.cuitrip.service.R;
import com.lab.app.customui.CustomUiConfig;
import com.lab.app.customui.CustomUiFragmentActivity;

/**
 * Created on 7/22.
 */
public class CancelOrderSuccessActivity extends CustomUiFragmentActivity {
    public static final String ORDER_INFO = "ORDER_INFO";
    private OrderItem mOrderInfo;

    protected void onCreate(Bundle savedInstanceState) {
        Intent intent = getIntent();
        if (intent == null) {
            finish();
            return;
        }
        mOrderInfo = (OrderItem) intent.getSerializableExtra(CancelOrderSuccessActivity.ORDER_INFO);
        if (mOrderInfo == null) {
            finish();
            return;
        }
        super.onCreate(savedInstanceState, R.layout.ct_order_cancel_sux);
    }

    @Override
    public void initListener() {
        TextView textView= (TextView) findViewById(R.id.cancel_action);
        final boolean isTraveller = LoginInstance.getInstance().getUserInfo().isTravel();
        textView.setText(isTraveller
                ?getString(R.string.operation_continue_exploring)
                :getString(R.string.operation_view_book));
        textView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (isTraveller) {
                    IndexActivity.gotoTab(CancelOrderSuccessActivity.this, IndexActivity.RECOMMEND_TAB_INDEX);
                } else {
                    IndexActivity.gotoTab(CancelOrderSuccessActivity.this, IndexActivity.ORDER_TAB_INDEX);
                }
                finish();
            }
        });
    }

    @Override
    public boolean initCloseTopBar() {
        return true;
    }

    @Override
    public void onTopbarLeftPress() {
        finish();
    }

    @Override
    public CustomUiConfig initCustomUiConfig() {
        return null;
    }
}
